<?php

/**
 * Desc
 * @description Holp You Do Good But Not Evil
 * @copyright   Copyright 2014-2015 <ycchen@iwshop.cn>
 * @license     LGPL (http://www.gnu.org/licenses/lgpl.html)
 * @author      Chenyong Cai <ycchen@iwshop.cn>
 * @package     Wshop
 * @link        http://www.iwshop.cn
 */
include_once dirname(__FILE__) . '/../system/Model.php';
include_once dirname(__FILE__) . '/Db.php';

class mWdmin extends Model {

    /**
     * login qrcodeScan listen
     * @param type $code
     */
    public function loginQrcodeScaned($code, $openid) {
        if (!isset($this->Db)) {
            $this->Db = new Db();
        }
        $code = substr($code, 4);
        $this->Db->query(sprintf("UPDATE `admin_login_code_token` SET used = 1,bind = '%s' WHERE tid = %s;", $openid, $code));
        $access_token = WechatSdk::getServiceAccessToken();
        Messager::sendText($access_token, $openid, '后台扫描登录成功！');
    }

    public function genLoginToken($ip) {
        
    }

}
